<?php
/**
 *
 * ============================================================================
 * * 版权所有 度拉拉 * *
 * 网站地址: http://www.dlltrip.com
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * Author By: 倪宗锋
 * PhpStorm LoginController.php
 * Create By 2017/6/13 15:11 $
 */

namespace admin\controllers\user;


use admin\service\user\Login;
use yii\web\Controller;

class LoginController extends Controller
{

    private  $service = null;
    public function service()
    {
        if($this->service == null) {
            $this->service = new Login();
        }
        return $this->service;
    }

    /**
 * Des:登录页面
 * Name: actionIndex
 * @return string
 * @author 倪宗锋
 */
    public function actionIndex()
    {
        $this->viewPath = ROOT_PATH . "/web/admin/dist/";
        $this->view->defaultExtension = 'html';
        return $this->render('login');
    }

    /**
     * Des:处理登录
     * Name: actionDoLogin
     * @return string
     * @author 倪宗锋
     */
    public function actionDoLogin()
    {
        $params = [
            'u_name' => $_POST['u_name'],//用户名
            'pwd' => $_POST['pwd']//密码
        ];
        $doLogin = $this->service()->doLogin($params);
        return json_encode($doLogin);
    }

}